import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InformationVO, InformationForm, InformationQuery } from '@/api/zichanguanli/information/types';

/**
 * 查询土地信息列表
 * @param query
 * @returns {*}
 */

export const listInformation = (query?: InformationQuery): AxiosPromise<InformationVO[]> => {
  return request({
    url: '/zichanguanli/information/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询土地信息详细
 * @param id
 */
export const getInformation = (id: string | number): AxiosPromise<InformationVO> => {
  return request({
    url: '/zichanguanli/information/' + id,
    method: 'get'
  });
};

/**
 * 新增土地信息
 * @param data
 */
export const addInformation = (data: InformationForm): AxiosPromise<string | number> => {
  return request({
    url: '/zichanguanli/information',
    method: 'post',
    data: data
  });
};

/**
 * 新增土地收租计划
 * @param data
 */
export const addRentCollectionPlan = (data: any): AxiosPromise<string | number> => {
  return request({
    url: '/system/rentCollectionPlan',
    method: 'post',
    data: data
  });
};

/**
 * 查询土地收租计划列表
 * @param data
 */
export const rentCollectionPlanList = (params: any): AxiosPromise<string | number> => {
  return request({
    url: '/system/rentCollectionPlan/list',
    method: 'get',
    params
  });
};

/**
 * 修改土地收租计划
 * @param data
 */
export const updateRentCollectionPlan = (data: any): AxiosPromise<string | number> => {
  return request({
    url: '/system/rentCollectionPlan',
    method: 'put',
    data: data
  });
};

/**
 * 修改土地信息
 * @param data
 */
export const updateInformation = (data: InformationForm) => {
  return request({
    url: '/zichanguanli/information',
    method: 'put',
    data: data
  });
};

/**
 * 删除土地信息
 * @param id
 */
export const delrentCollectionPlan = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/rentCollectionPlan/' + id,
    method: 'delete'
  });
};

/**
 * 删除土地信息
 * @param id
 */
export const delInformation = (id: string | number | Array<string | number>) => {
  return request({
    url: '/zichanguanli/information/' + id,
    method: 'delete'
  });
};
